import java.util.*;
public class tollsystem {
    static class vehicle{
        String platenumber;
        double distance;
        double weight;
        void toll(){

        }
    }
    static   class car extends vehicle {

        void toll(){
            System.out.println("小汽车收费"+0.5*distance+"元");
        }
    }
    static  class bus extends vehicle {

        void toll (){
            System.out.println("大巴车收费"+1.0*distance+"元");
        }
    }
    static   class truck extends vehicle {



        void toll (){
            System.out.println("卡车收费"+5*distance*weight+"元");
        }
    }

    public static void main(String[] args) {
        String type;
        vehicle a;
        String platenumber;
        Scanner sc=new Scanner(System.in);
        while(true){
            System.out.println("请输入车的类型:car bus truck");
            type= sc.next();
            System.out.println("请输入车牌号");
            platenumber= sc.next();
            System.out.println("正在查询是否有违章记录");
            String []record={"有","无"};
            int b=(int)(Math.random()*2);
            String c=record[b];
            if (c.equals("有"))
            {
                System.out.println("有违章记录");
            }
            else
            { System.out.println(c+"违章记录");
                if (type.equals("car")){
                    a=new car();
                    System.out.println("请输入公里数");
                    a.distance= sc.nextDouble();
                    a.toll();
                }
                else if (type.equals("bus")){
                    a=new bus();
                    System.out.println("请输入公里数");
                    a.distance= sc.nextDouble();
                    a.toll();}
                else if (type.equals("truck")){
                    a=new truck();
                    System.out.println("请输入公里数");
                    a.distance= sc.nextDouble();
                    System.out.println("请输入载重量");
                    a.weight=sc.nextDouble();
                    a.toll();
                }

                System.out.println("请缴费");
                System.out.println("缴费成功");
                System.out.println("谢谢，再见，祝您一路顺风");}
        }

    }
}

